package com.photonpay.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 交易状态类型
 *
 * @author ：lo-
 * @date ：Created in 2023/11/23 11:56
 */
@Getter
@AllArgsConstructor
public enum TransactionStatusEnum {

    /**
     * 挂起
     */
    PENDING("pending"),

    /**
     * 授权中
     */
    AUTHORIZED("authorized"),

    /**
     * 成功
     */
    SUCCEED("succeed"),

    /**
     * 失败
     */
    FAILED("failed"),

    /**
     *
     */
    VOID("void"),

    /**
     *
     */
    PROCESSING("processing"),

    ;

    private final String code;

    public static TransactionStatusEnum getByCode(String code) {
        for (TransactionStatusEnum status : TransactionStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的交易类型 code: " + code);
    }
}
